﻿<Window x:Class="MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:Vivei.Tools.Application"
        Title="MainWindow" 
        Height="350" 
        Width="525"
        WindowStyle="None"
        ResizeMode="CanResizeWithGrip"
        WindowStartupLocation="CenterScreen" 
        WindowState="Maximized"
        AllowsTransparency="True" 
        DataContext="{x:Static local:App.UIService}">
    <Border Background="Gray" Padding="5">
        <Grid Background="Gray">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition />
            </Grid.RowDefinitions>
            <Grid Margin="2">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition  />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <TextBlock Foreground="White"  VerticalAlignment="Center" HorizontalAlignment="Left" Text="Application Vivei" FontWeight="Bold"  />
                <Thumb BorderBrush="{x:Null}" BorderThickness="0" Name="DragMainWindowThumb" Grid.Column="1" Background="Gray">
                    <Thumb.Template>
                        <ControlTemplate TargetType="Thumb">
                            <Border Background="{TemplateBinding Background}" />
                        </ControlTemplate>
                    </Thumb.Template>
                </Thumb>
                <StackPanel Grid.Column="2" HorizontalAlignment="Right"   Orientation="Horizontal" >
                    <Button Width="25" Height="25" Name="HideMainWindowButton"  />
                    <Button Width="25" Height="25" Name="ResizeMainWindowButton" />
                    <Button Width="25" Height="25" Name="CloseMainWindowButton" />
                </StackPanel>
            </Grid>
            <Grid Name="MainGrid" Background="Gray" Grid.Row="1" >
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="250" MinWidth="100" />
                    <ColumnDefinition Width="5" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="*" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>

                <GridSplitter Background="Gray" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" 
                          Margin="0,35,0,0"
                          Grid.Column="1" Grid.RowSpan="3" />

                <Menu  Grid.ColumnSpan="3" ItemsSource="{Binding Menu}">
                    <Menu.ItemContainerStyle>
                        <Style TargetType="MenuItem">
                            <Setter Property="Command" >
                                <Setter.Value>
                                    <Binding Path="OnClick">
                                        <Binding.Converter>
                                            <local:ActionToCommandConverter />
                                        </Binding.Converter>
                                    </Binding>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </Menu.ItemContainerStyle>
                    <Menu.ItemTemplate>
                        <HierarchicalDataTemplate  ItemsSource="{Binding Children}" >
                            <TextBlock Margin="3" VerticalAlignment="Center" Text="{Binding Caption}" FontWeight="Bold"/>
                        </HierarchicalDataTemplate>
                    </Menu.ItemTemplate>
                </Menu>

                <StatusBar Grid.Row="2" Grid.ColumnSpan="3">
                    <StatusBarItem Content="Loading Module ..." />
                </StatusBar>

                <TabControl DataContext="{Binding ElementName=NavigationTree, Path=SelectedItem, Mode=OneWay}"
                            Margin="0,5,0,0" Grid.Column="2" Grid.Row="1"
                          SelectedItem="{Binding Path=View, Mode=OneWay}"
                          ItemsSource="{Binding Path=Views, Mode=OneWay}">
                    <!--<TabControl.ItemsSource>
                        <Binding>
                            <Binding.Converter>
                                <local:NodeCollectionToViewCollection />
                            </Binding.Converter>
                        </Binding>
                    </TabControl.ItemsSource>-->
                    <!--<TabControl.ItemTemplate>
                     
                    </TabControl.ItemTemplate>-->    
                    <TabControl.ItemContainerStyle>
                        <Style TargetType="TabItem">
                            <Setter Property="Header" Value="{Binding Caption}" />
                            <Setter Property="HeaderTemplate" >
                                <Setter.Value>
                                    <DataTemplate>
                                        <TextBlock FontSize="14" FontWeight="Bold"  Text="{Binding}" VerticalAlignment="Center" Margin="10,0,0,0" />
                                    </DataTemplate>
                                </Setter.Value>
                            </Setter>                          
                        </Style>
                    </TabControl.ItemContainerStyle>
                </TabControl>

                <Grid Grid.Row="1">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="*" />
                        <RowDefinition Height="5" />
                        <RowDefinition Height="Auto" MinHeight="100" />

                    </Grid.RowDefinitions>

                    <TextBlock HorizontalAlignment="Center" 
                           VerticalAlignment="Center" 
                           Text="Arborescence" Margin="14" FontWeight="Bold" Foreground="White" />

                    <TreeView Name="NavigationTree" Grid.Row="1" ItemsSource="{Binding NavigationGroup/Nodes}"
                          HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" >
                        <TreeView.ItemContainerStyle>
                            <Style TargetType="TreeViewItem">
                                <Setter Property="IsExpanded" Value="{Binding Path=Expanded, Mode=TwoWay}" />
                                <Setter Property="ContextMenu">
                                    <Setter.Value>
                                        <ContextMenu  ItemsSource="{Binding ContextualMenu}">
                                            <ContextMenu.ItemContainerStyle>
                                                <Style TargetType="MenuItem">
                                                        <Setter Property="Command" >
                                                        <Setter.Value>
                                                            <Binding Path="OnClick">
                                                                <Binding.Converter>
                                                                    <local:ActionToCommandConverter />
                                                                </Binding.Converter>
                                                            </Binding>
                                                        </Setter.Value>
                                                    </Setter>
                                                </Style>
                                            </ContextMenu.ItemContainerStyle>
                                            <ContextMenu.ItemTemplate>
                                                <HierarchicalDataTemplate  ItemsSource="{Binding Children}" >
                                                    <TextBlock Margin="3" VerticalAlignment="Center" Text="{Binding Caption}"/>
                                                </HierarchicalDataTemplate>
                                            </ContextMenu.ItemTemplate>
                                        </ContextMenu>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </TreeView.ItemContainerStyle>
                        <TreeView.ItemTemplate>
                            <HierarchicalDataTemplate  ItemsSource="{Binding Children}" >
                                <TextBlock Margin="3" VerticalAlignment="Center" Text="{Binding Caption}" FontWeight="Bold"/>
                            </HierarchicalDataTemplate>
                        </TreeView.ItemTemplate>
                    </TreeView>

                    <GridSplitter HorizontalAlignment="Stretch" 
                              VerticalAlignment="Stretch" 
                              Grid.Row="2" Background="Gray"   />

                    <ListBox  Grid.Row="3" ItemsSource="{Binding NavigationGroup}" IsSynchronizedWithCurrentItem="True"
                         HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" >
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <TextBlock FontSize="14" FontWeight="Bold"  Text="{Binding Caption}" VerticalAlignment="Center" Margin="10,0,0,0" />
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                        <ListBox.ItemContainerStyle>
                            <Style TargetType="ListBoxItem">
                                <Setter Property="Height" Value="50"  />
                            </Style>
                        </ListBox.ItemContainerStyle>

                    </ListBox>
                </Grid>
            </Grid>
            <Grid Grid.Row="1"  Name="LoadingGrid"/>
        </Grid>
    </Border>
</Window>
